﻿using System.ComponentModel;
using DevExpress.XtraEditors.DXErrorProvider;
using Dogshow.Model.Validation;
using Dogshow.Win.Helpers;
using FluentValidation.Results;

namespace Dogshow.Win.Models
{
    public class Mesto : Model.Mesto, IValidatable
    {
        public readonly static MestoValidator s_Validator = new MestoValidator();

        public void GetPropertyError(string propertyName, ErrorInfo info)
        {
            this.GetErrorsForProperty(propertyName, info);
        }

        public void GetError(ErrorInfo info)
        {
            this.GetErrors(info);
        }

        [Browsable(false)]
        public bool IsValid { get; set; }

        public ValidationResult Validate()
        {
            var r = s_Validator.Validate(this);
            IsValid = r.IsValid;
            return r;
        }
    }
}